package ninja9.muzik.dao;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Album entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "album", catalog = "muzik")
public class Album implements java.io.Serializable {

	// Fields

	private Integer id;
	private Singer singer;
	private String albumName;
	private String coverImage;
	private Integer year;
	private Set<Song> songs = new HashSet<Song>(0);

	// Constructors

	/** default constructor */
	public Album() {
	}

	/** minimal constructor */
	public Album(Singer singer, String albumName, String coverImage,
			Integer year) {
		this.singer = singer;
		this.albumName = albumName;
		this.coverImage = coverImage;
		this.year = year;
	}

	/** full constructor */
	public Album(Singer singer, String albumName, String coverImage,
			Integer year, Set<Song> songs) {
		this.singer = singer;
		this.albumName = albumName;
		this.coverImage = coverImage;
		this.year = year;
		this.songs = songs;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "singer_id", nullable = false)
	public Singer getSinger() {
		return this.singer;
	}

	public void setSinger(Singer singer) {
		this.singer = singer;
	}

	@Column(name = "album_name", nullable = false, length = 65535)
	public String getAlbumName() {
		return this.albumName;
	}

	public void setAlbumName(String albumName) {
		this.albumName = albumName;
	}

	@Column(name = "cover_image", nullable = false, length = 65535)
	public String getCoverImage() {
		return this.coverImage;
	}

	public void setCoverImage(String coverImage) {
		this.coverImage = coverImage;
	}

	@Column(name = "year", nullable = false)
	public Integer getYear() {
		return this.year;
	}

	public void setYear(Integer year) {
		this.year = year;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "album")
	public Set<Song> getSongs() {
		return this.songs;
	}

	public void setSongs(Set<Song> songs) {
		this.songs = songs;
	}

}